package com.book.item.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.book.item.mapper.BookMapper;
import com.book.item.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.buchong.pojo.Book;

import java.util.List;

@Service
@Transactional
public class IBookService extends ServiceImpl<BookMapper, Book> implements BookService {
    @Autowired
    private BookMapper bookMapper;
    @Override
    public List<Book> findAll() {
        return bookMapper.selectList(null);
    }

    @Override
    public List<Book> findByID(Integer id) {
        return bookMapper.selectList(new QueryWrapper<Book>().eq("categoryID",id));
    }

    @Override
    public Book findOne(Integer id) {
        return bookMapper.selectById(id);
    }

    @Override
    public List<Book> selByName(String name) {
        return bookMapper.selectList(new QueryWrapper<Book>().like("name",name));
    }
}
